home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / etc / wpa_supplicant / wpa_cli.sh
Encoding:
Linux/UNIX/POSIX Shell Script  |  2006-05-15  |  1.2 KB  |  45 lines

  1. #!/bin/sh
  2. # Copyright 1999-2006 Gentoo Foundation
  3. # Written by Roy Marples <uberlord@gentoo.org>
  4. # Distributed under the terms of the GNU General Public License v2
  5. # Alternatively, this file may be distributed under the terms of the BSD License
  6. # $Header: /var/cvsroot/gentoo-x86/net-wireless/wpa_supplicant/files/wpa_supplicant-0.5.3-wpa_cli.sh,v 1.1 2006/04/29 14:28:48 brix Exp $
  7.  
  8. if [ -z "$1" -o -z "$2" ]; then
  9.     echo "Insufficient parameters" > /dev/stderr
  10.     exit 1
  11. fi
  12.  
  13. INTERFACE="$1"
  14. ACTION="$2"
  15.  
  16. # Note, the below action must NOT mark the interface down via ifconfig, ip or
  17. # similar. Addresses can be removed, changed and daemons can be stopped, but
  18. # the interface must remain up for wpa_supplicant to work.
  19.  
  20. if [ -f /etc/gentoo-release ]; then
  21.     EXEC="/etc/init.d/net.${INTERFACE} --quiet"
  22. else
  23.     echo "I don't know what to do with this distro!" > /dev/stderr
  24.     exit 1
  25. fi
  26.  
  27. case ${ACTION} in
  28.     CONNECTED)
  29.         EXEC="${EXEC} start"
  30.         ;;
  31.     DISCONNECTED)
  32.         EXEC="${EXEC} stop"
  33.         ;;
  34.     *)
  35.         echo "Unknown action ${ACTION}" > /dev/stderr
  36.         exit 1
  37.         ;;
  38. esac
  39.  
  40. # ${EXEC} can use ${IN_BACKGROUND} so that it knows that the user isn't
  41. # stopping the interface and a background process - like wpa_cli - is.
  42. export IN_BACKGROUND=true
  43.  
  44. ${EXEC}
  45.